<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>第四届 IT农场报名表</title>

    <!-- Bootstrap -->
    <link href="./css/bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="./css/bootstrapValidator.css" />

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
    <div class="container">
        <div class="row">
            <!-- form: -->
            <section>
                <div class="col-md-9">
                    <form id="defaultForm" method="post" class="form-horizontal" action="./Registration">
                        <fieldset>

                            <div id="legend" class="">
                                <legend class="">基本信息</legend>
                            </div>


                            <div class="form-group">
                                <label class="col-md-3 control-label">团队名</label>
                                <div class="col-md-5">
                                    <input type="text" class="form-control" placeholder="团队名" name="team_name" />
                                </div>
                            </div>



                            <div class="form-group">
                                <label class="col-md-3 control-label">团队类型</label>
                                <div class="col-md-5">
                                    <div>
                                        <label class="radio inline radio-inline">
                                        <input  type="radio" name="team_type" value="1" /> 应用
                                    </label>
                                    </div>
                                    <div>
                                        <label class="radio inline radio-inline">
                                        <input type="radio" name="team_type" value="2" /> 游戏
                                    </label>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label">负责人姓名</label>
                                <div class="col-md-5">
                                    <input type="text" class="form-control" placeholder="XXX" name="master_name" />
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-md-3 control-label">负责人学号</label>
                                <div class="col-md-5">
                                    <input type="text" class="form-control" placeholder="20XXXXXXXXXX" name="master_id" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-md-3 control-label">负责人年级</label>
                                <div class="col-md-5">
                                    <select class="form-control" name="master_level" data-bv-notempty data-bv-notempty-message="年级是必须的">
                                        <option value="" >--选择年级--</option>
                                        <option value="13">13</option>
                                        <option value="14">14</option>
                                        <option value="15">15</option>
                                        
                                        <option value="16">16</option>
                                    </select>
                                </div>
                            </div>

                            <div data-toggle="distpicker">
                                <div class="form-group">

                                    <label class="col-md-3 control-label " for="province1">学院</label>
                                    <div class="col-md-5">
                                        <select class="form-control" id="province1" name="master_collage"></select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class=" col-md-3 control-label" for="city1">专业</label>
                                    <div class="col-md-5">
                                        <select class="form-control" id="city1" name="master_major"></select></div>
                                </div>


                            </div>


                            <div class="form-group">
                                <label class="col-md-3 control-label">联系方式</label>
                                <div class="col-md-5">
                                    <input type="text" class="form-control" placeholder="158XXXXXXXX/66XXXX" name="master_phone" />
                                    <p class="help-block">输入长号或短号</p>
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-md-3 control-label">QQ或微信</label>
                                <div class="col-md-5">
                                    <input type="text" class="form-control" placeholder="12345678" name="master_qq" />
                                    <p class="help-block">留下你的QQ或者微信号，方便拉你进群</p>
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-md-3 control-label">联系人邮箱</label>
                                <div class="col-md-5">
                                    <input type="text" class="form-control" name="master_email" />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label">团队人数</label>
                                <div class="col-md-5">
                                    <select class="form-control" name="user_count" data-bv-notempty data-bv-notempty-message="人数是必须的">
                                        
                                        <option value="1" checked="checked">1</option>
                                        <option value="2">2</option>
                                        <option value="3">3</option>
                                        <option value="4">4</option>
                                        <option value="5">5</option>
                                        <option value="6">6</option>
                                    </select>
                                    <p class="help-block">含队长</p>
                                </div>
                            </div>

                            <div name="userlist"></div>



                            <div class="form-group">
                                <div class="col-md-9 col-md-offset-3">
                                    <button type="submit" class="btn btn-primary" name="submit" value="submit">提交</button>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
            </section>
            <!-- :form -->
        </div>
    </div>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script type="text/javascript" src="./js/jquery-1.11.2.min.js"></script>

    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script type="text/javascript" src="./js/bootstrap.js"></script>

    <script type="text/javascript" src='./js/baiduTemplate.js'></script>
    <script type="text/javascript" src="./js/module/user.js"></script>
    <script type="text/javascript" type="text/javascript" src="./js/bootstrapValidator.js"></script>
    <script type="text/javascript" src="./js/chack.js"></script>


    <script src="js/distpicker.data.js"></script>
    <script src="js/distpicker.js"></script>
    <script type="text/javascript">
        function ajaxSubmit(frm, fn) {
            var dataPara = getFormJson(frm);
            //console.log(frm);
            $.ajax({
                url: frm.action,
                type: frm.method,
                data: dataPara,
                success: fn
            });
        }


        function getFormJson(frm) {
            var o = {};
            var a = $(frm).serializeArray();
            $.each(a, function() {
                if (o[this.name] !== undefined) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });

            return o;
        }

        $(document).ready(function() {


            $("div[name=userlist]").html(auditTemplate());
            $('select[name=user_count]').change(function(e) {
                console.log(e);


                var $selectedvalue = e.target.selectedIndex

                for (var n = 0; n < 5; n++) {
                    if (n < parseInt($selectedvalue))
                        $("#user" + n).attr("class", "null");
                    else {
                        $("#user" + n).attr("class", "hide");
                    }
                }

                //alert($selectedvalue);



            })


            $('#defaultForm').on('success.form.bv', function(e) {
                e.preventDefault();
                console.log('success.form.bv');

                // If you want to prevent the default handler (bootstrapValidator._onSuccess(e))


                ajaxSubmit(this, function(data) {





                });
                alert("提交成功");




            })

            $('.form-horizontal').bind('submit', function(event) {
                event.preventDefault();
                ajaxSubmit(this, function(data) {





                });
                //console.log(event.type);
                return false;
            });

            $('[data-toggle="distpicker"]').distpicker();

        });

    </script>
</body>

</html>
